cleanup whining about validate filter, and add test. (#197)
authortsteven4 <tsteven4@users.noreply.github.com>
Sun, 17 Jun 2018 16:57:09 +0000 (10:57 -0600)
committerGitHub <noreply@github.com>
Sun, 17 Jun 2018 16:57:09 +0000 (10:57 -0600)
reference/empty.gpx [new file with mode: 0644]
reference/validate_debug.log [new file with mode: 0644]
reference/validate_empty.log [new file with mode: 0644]
testo.d/validate.test [new file with mode: 0644]
validate.cc

diff --git a/reference/empty.gpx b/reference/empty.gpx
new file mode 100644 (file)
index 0000000..f82a1f7
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="MapSource 6.12.2" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+</gpx>
diff --git a/reference/validate_debug.log b/reference/validate_debug.log
new file mode 100644 (file)
index 0000000..85e4f47
--- /dev/null
@@ -0,0 +1,13 @@
+
+Processing waypts
+point ct: 2, waypt_count: 2
+
+Processing routes
+route 0 ct: 2, waypt_count: 2
+route head ct: 1, route_count: 1
+total route point ct: 2, route_waypt_count: 2
+
+Processing tracks
+track 0 ct: 2, waypt_count: 2
+track head ct: 1, track_count: 1
+total track point ct: 2, track_waypt_count: 2
diff --git a/reference/validate_empty.log b/reference/validate_empty.log
new file mode 100644 (file)
index 0000000..72f1000
--- /dev/null
@@ -0,0 +1 @@
+validate:No input
diff --git a/testo.d/validate.test b/testo.d/validate.test
new file mode 100644 (file)
index 0000000..64b8f3a
--- /dev/null
@@ -0,0 +1,9 @@
+gpsbabel -i gpx -f ${REFERENCE}/basecamp.gpx -x validate,debug > /dev/null 2> ${TMPDIR}/validate_debug.log
+compare ${REFERENCE}/validate_debug.log ${TMPDIR}/validate_debug.log
+
+# expecting this to fail so call directly rather than via gpsbabel function
+${PNAME} -i gpx -f ${REFERENCE}/empty.gpx -x validate,checkempty > /dev/null 2> ${TMPDIR}/validate_empty.log && {
+  echo "${PNAME} succeeded! (it shouldn't have with this input...)"
+}
+compare ${REFERENCE}/validate_empty.log ${TMPDIR}/validate_empty.log
+
index 2aa67434f55abc8b18eb071bbde30e1f0edb04be..8d5d9a4c745b0af041de883450fa3641933ea81a 100644 (file)
@@ -85,10 +85,10 @@ validate_process()
   }
   waypt_disp_all(validate_point);
   if (debug) {
-    fprintf(stderr, "point ct: %d, waypt_count: %d\n", point_ct, waypt_count());
+    fprintf(stderr, "point ct: %u, waypt_count: %u\n", point_ct, waypt_count());
   }
   if (!debug && (point_ct != waypt_count())) {
-    fatal(MYNAME ":Waypoint count mismatch, expected %d, actual %d\n", waypt_count(), point_ct);
+    fatal(MYNAME ":Waypoint count mismatch, expected %u, actual %u\n", waypt_count(), point_ct);
   }
 
   head_ct = 0;
@@ -99,14 +99,14 @@ validate_process()
   }
   route_disp_all(validate_head, validate_head_trl, validate_point);
   if (debug) {
-    fprintf(stderr, "route head ct: %d, route_count: %d\n", head_ct, route_count());
-    fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", point_ct, route_waypt_count());
+    fprintf(stderr, "route head ct: %u, route_count: %u\n", head_ct, route_count());
+    fprintf(stderr, "total route point ct: %u, route_waypt_count: %u\n", point_ct, route_waypt_count());
   }
   if (!debug && (head_ct != route_count())) {
-    fatal(MYNAME ":Route count mismatch, expected %d, actual %d\n", route_count(), head_ct);
+    fatal(MYNAME ":Route count mismatch, expected %u, actual %u\n", route_count(), head_ct);
   }
   if (!debug && (point_ct != route_waypt_count())) {
-    fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), point_ct);
+    fatal(MYNAME ":Total route waypoint count mismatch, expected %u, actual %u\n", route_waypt_count(), point_ct);
   }
 
   head_ct = 0;
@@ -117,14 +117,14 @@ validate_process()
   }
   track_disp_all(validate_head, validate_head_trl, validate_point);
   if (debug) {
-    fprintf(stderr, "track head ct: %d, track_count: %d\n", head_ct, track_count());
-    fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", point_ct, track_waypt_count());
+    fprintf(stderr, "track head ct: %u, track_count: %u\n", head_ct, track_count());
+    fprintf(stderr, "total track point ct: %u, track_waypt_count: %u\n", point_ct, track_waypt_count());
   }
   if (!debug && (head_ct != track_count())) {
-    fatal(MYNAME ":Track count mismatch, expected %d, actual %d\n", track_count(), head_ct);
+    fatal(MYNAME ":Track count mismatch, expected %u, actual %u\n", track_count(), head_ct);
   }
   if (!debug && (point_ct != track_waypt_count())) {
-    fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), point_ct);
+    fatal(MYNAME ":Total track waypoint count mismatch, expected %u, actual %u\n", track_waypt_count(), point_ct);
   }
 
   if (checkempty) {